import React from 'react'
import {Table} from 'antd'
// import {DeleteOutlined} from '@ant-design/icons'
// import { Switch } from 'react-router'
// const { confirm } = Modal;
export default function NewsPublish(props){ 
      const columns = [
        {
            // 列表标题
          title: '新闻标题',
        //   列表内容名称
          dataIndex: 'title',
          render:(title,item)=>{
              return <a href={`#/news-manage/preview/${item.id}`}>{title}</a>
          }
        },
        {
          title: '作者',
          dataIndex: 'author',
        },
        {
          title: '新闻分类',
          dataIndex: 'category',
          render:(category)=>{
              return <div>{category.title}</div>
          }
        },
        {
            title:'操作',
            render:(item)=>{
                return (
                    <div>
                        {/* 按钮 */}
                        {/* 传达当前所点击的id */}
                        {props.button(item.id)}
                    </div>
                )
            }
        }
      ];
    return (
        <div>
            <Table dataSource={props.dataSource} columns={columns} 
            rowKey={(item)=>item.id}
            pagination={{
                pageSize:7
            }}/>
        </div>
    )
}
